package util2;

import java.util.Random;
import java.util.concurrent.CountDownLatch;

public class CountDownLautchUtil {

	public static void main(String[] args) {
		CountDownLatch countDown = new CountDownLatch(10);
		for (int i = 0; i < 10; i++) {
			new Thread(()->{
				try {
					Thread.sleep(new Random().nextInt(1000));
					System.out.println(Thread.currentThread().getName()+":就位");
					countDown.countDown();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
//					System.out.println(Thread.currentThread().getName()+":事情做完了");
				
				
			}).start();
		}
		try {
			countDown.await();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("人都到齐了，我们出发了.........");
	}

}
